Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering bug of Markdown Code. #14638

Merged
merged 1 commit into from
Jan 12, 2016
Merged

Conversation

hayd
Copy link
Member

@hayd hayd commented Jan 11, 2016

When a code block included a ```, it would not be rendered correctly.

cc @MichaelHatherly

println(io, "```", code.language)
# If the code includes a fenced block this will break parsing,
# so it must be enclosed by a longer ````-sequence.
n = mapreduce(length, max, matchall(r"`+", code.code)) + 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the regex only match backticks that begin at the start of a line, ie r"^+"m`?

Also, if code.code contains no matches mapreduce would throw

julia> mapreduce(length, max, matchall(r"`+", ""))
ERROR: ArgumentError: reducing over an empty collection is not allowed
 in _mapreduce at ./reduce.jl:139
 in mapreduce at ./reduce.jl:159
 in mapreduce at ./reduce.jl:162
 in eval at ./boot.jl:265

since matchall returns a 0-length vector. Is that a valid edge case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, so it can be:

mapreduce(length, max, 1, matchall(r"^`+"m, code.code))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapreduce(length, max, 3, matchall(r"^`+"m, code.code))

? To avoid setting n = 1.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right. Though you actually still need the + 1 in there. Have updated.

@hayd hayd force-pushed the fix_plain_code branch 3 times, most recently from 1cc38cb to c9a9181 Compare January 11, 2016 08:51
When a code block included a ```, it would not be rendered correctly.
@hayd
Copy link
Member Author

hayd commented Jan 11, 2016

The 64 bit travis error is surely unrelated:

LoadError: start_watching (FileMonitor): no space left on device (ENOSPC)

hayd added a commit that referenced this pull request Jan 12, 2016
Fix rendering bug of Markdown Code.
@hayd hayd merged commit b97efac into JuliaLang:master Jan 12, 2016
@hayd hayd deleted the fix_plain_code branch January 12, 2016 00:36
tkelman pushed a commit that referenced this pull request Mar 7, 2016
When a code block included a ```, it would not be rendered correctly.

(cherry picked from commit 60eda14)
ref #14638
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants